/***************************************************************
 * Name:      IrReaderClient.cpp
 * Purpose:   Base of IrReader Client
 * Author:    Jimmy F.Klarke (isjfk@163.com)
 * Created:   2009-08-15
 * Copyright: Jimmy F.Klarke (http://www.isjfk.org)
 * License:
 **************************************************************/

#ifndef IRREADERCLIENT_H
#define IRREADERCLIENT_H

#include <vector>
#include <string>

#define MCU_WRITE_SIG_LEN   0x01

using namespace std;

class IrReaderClient
{
    public:

        IrReaderClient();
        virtual ~IrReaderClient();

        bool isMcuWriteSigLen();
        void setMcuWriteSigLen(bool writeSigLen);

        virtual vector<string> getPortList()        = 0;
        virtual string getPortDefault()             = 0;
        virtual vector<string> getBaudList()        = 0;
        virtual string getBaudDefault()             = 0;
        virtual vector<string> getDataBitSizeList() = 0;
        virtual string getDataBitSizeDefault()      = 0;
        virtual vector<string> getStopBitSizeList() = 0;
        virtual string getStopBitSizeDefault()      = 0;
        virtual vector<string> getParityList()      = 0;
        virtual string getParityDefault()           = 0;
        virtual vector<string> getFlowCtrlList()    = 0;
        virtual string getFlowCtrlDefault()         = 0;

        virtual void openClient(
                string port,
                string baud,
                string dataBitSize,
                string stopBitSize,
                string parity,
                string flowCtrl)                    = 0;
        virtual void closeClient()                  = 0;

        virtual vector<unsigned char> read()        = 0;
        virtual void writeConfig()                  = 0;

    protected:

        unsigned char mcuConfig[1];
};


class IrReaderClientException
{
    public:

        static const int UNKNOWN_ERROR = -1;

        IrReaderClientException(int code);
        IrReaderClientException(string msg);
        IrReaderClientException(int code, string msg);

        int getCode();
        string getMsg();

    protected:

        int code;
        string msg;
};

#endif // IRREADERCLIENT_H
